<?xml version="1.0"?>
<OnTheFlyInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <InstanceId>Enterprise Search - Get Metadata</InstanceId>
  <CustomAppConfig />
  <Tags>
    <string>SharePoint Web Services</string>
  </Tags>
  <AdditionalAssemblies />
  <Code><![CDATA[// ----------------------
// SharePoint Search Web Service call using SQL syntax
// ----------------------

using System;
using System.Linq;
using SP2010.searchWS;
using xSolon.Instructions;
using xSolon.SP.WS;
using xSolon.Instructions.DTO;
namespace xSolon.SP.Samples
{
    public class SearchGetMetadata : AbstractInstruction
    {
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public override void Run()
        {
            var inst1 = new Search();

            inst1.NotifyEvent += NotifyGeneric;

            inst1.SPUrl = "http://localhost";

            #region Authentication

            inst1.Authentication = new AuthenticationParams()

            {
                UseDefaultCredentials = true,
                UserName = "username",
                Domain = "domain",
                Password = "password",
                Authentications = AuthenticationType.Windows
            };

            #endregion

            inst1.OnRunAction = new Action<QueryService>((svc) =>
            {
				Response = svc.Query(@"<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>
			<Query>
				<Context>
					<QueryText language='en-US' type='MSSQLFT'>
SELECT Title,Rank,FOPostedDate,Path,FundingMechanism,FOFOId,foannouncementurl,FOIsFoNotShown 
FROM Scope() WHERE ""SCOPE"" = 'FundingOpps' 
AND (FOEXPIRATIONDATE IS NULL OR FOEXPIRATIONDATE &gt;= GETGMTDATE())
AND (FOIsFoNotShown IS NULL OR CONTAINS (FOIsFoNotShown,'""0""') )
ORDER BY ""FOPOSTEDDATE"" DESC
					</QueryText>
				</Context>
			</Query>
		</QueryPacket>");
		
			Response = Response.GetXmlDocument().Beautify();
			
            });

            inst1.Run();
        }
    }
}]]></Code>
</OnTheFlyInstruction>